package com.guli.cart.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/*
 * @Author 罗俊
 * @date 2020/11/9 - 4:32 下午
 *
 */
@Configuration
@Slf4j
public class ThreadPoolConfig {

    @Bean
    public ThreadPoolExecutor threadPoolExecutor(){

        LinkedBlockingDeque<Runnable> linkedBlockingDeque = new LinkedBlockingDeque<>(100);

        log.info("正在初始化线程池..");

        return new ThreadPoolExecutor(3,5,30, TimeUnit.SECONDS,linkedBlockingDeque);
    }
}
